import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsDate, IsNumber } from 'class-validator';

/**
 * 接受消息的参数实体
 */
export class CreateMessageDto {
  /**
   * 消息内容
   */
  @ApiProperty({
    required: true,
  })
  @IsString()
  messageInfo: string;

  /**
   * 发送者
   */
  @ApiProperty({
    required: true,
  })
  @IsString()
  sendUser: string;

  /**
   * 发送时间
   */
  @ApiProperty({
    required: true,
  })
  @IsDate()
  timestamp: Date;

  /**
   * 随机数，用来和前端确认消息是否一致
   */
  @ApiProperty({
    required: true,
  })
  @IsNumber()
  nonce: bigint | number;
}

/**
 * 插入消息的参数实体
 */
export class InsertMessageDto {
  messageInfo: string;
  sendUser: string;
  timestamp: Date;
  updater?: string;
  createTime: Date;
  creater: string;
  updateTime?: Date;
  deleted?: number;
}

/**
 * 返回消息的实体
 */
export class RespMessage {
  id: number;
  messageInfo: string;
  sendUser: string;
  timestamp: Date;
  nonce: bigint | number;
}
